package xml;

import java.util.*;
import cuShapes.*;
import javax.xml.bind.annotation.adapters.*;
import javax.xml.bind.annotation.*;

@XmlRootElement (name = "shapeCollection")
@XmlType(name = "ShapeCollectionType", propOrder={"shapes", "arrows"})
@XmlAccessorType(XmlAccessType.FIELD)
public class ShapeCollection {

	@XmlAttribute(required=true)
	private long id;
	
	@XmlJavaTypeAdapter(value=ShapeCollectionAdapter.class)
	@XmlElement(name="shapeslist")
	private List<PQShape> shapes = new ArrayList<PQShape>();
	@XmlJavaTypeAdapter(value=ArrowCollectionAdapter.class)
	@XmlElement(name="arrowsList")
	private List<PQShape> arrows = new ArrayList<PQShape>();

	public List<PQShape> getShapeList() {
		if (shapes == null) {
            shapes = new ArrayList<PQShape>();
        }
        return this.shapes;
	}
	public List<PQShape> getArrowList() {
		if (arrows == null) {
			arrows = new ArrayList<PQShape>();
		}
		return this.arrows;
	}
	
    // JAXB needs this default constructor
    public ShapeCollection() {}
    
    public ShapeCollection(List<PQShape> shapes, List<PQShape> arrows) {
        Calendar cal = new GregorianCalendar();
        this.setId(cal.getTimeInMillis());
        this.shapes = shapes;
        this.arrows = arrows;
    }

	public void setId(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}
}
